package com.thinklib.controller;

import com.github.pagehelper.PageInfo;
import com.thinklib.bean.Book;
import com.thinklib.bean.ExtCode;
import com.thinklib.service.SearchService;
import com.thinklib.util.JsonData;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/v1/search/")
public class SearchController {

    @Resource
    private SearchService searchService;

    @GetMapping("search_book")
    public PageInfo<Book> searchBookThread(HttpServletRequest request) {
        PageInfo pageInfo = searchService.searchBookThread(request);
        return pageInfo;
    }

    @GetMapping("get_ext_code")
    public JsonData getExtCode(@RequestParam("bookId") int bookId) {
        ExtCode extCode = searchService.findExtCodeByBookId(bookId);
        return JsonData.buildSuccess(extCode);
    }

}
